<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/easycommon.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>学生列表</title>
    <meta charset="utf-8">
<!--    <style>
    	html, body{ margin:0; height:100%; }
    	table{font-size:18px}
    	.input{width:250px;margin:4px;height:35px;border: 1px solid #ccc;font-size:18px;border-radius:4px}
    	label{margin:4px}		
    	.btn{width:100px;height:35px;border-radius:4px;background:#6CAEF5;font-size:18px;margin:15px}	
    </style>-->
    <script>
    var studentDataGrid; //定义全局变量datagrid
    $(function(){
    	studentDataGrid = $('#studentDataGrid').datagrid({
    		rownumbers:true,
    		//singleSelect:true,
    		pagination:true,
    		fit: true, //datagrid自适应宽度
            fitColumn: true, //列自适应宽度
            striped: true, //行背景交换
            nowap: false, //列内容多时自动折至第二行
            border: false,
            //idField: 'id', //主键
            width:465,
            height:'98%',
            method:'get',
    		url:"${path}/course/student?course_open_detailID=${requestScope.course_open_detailID}",
    		columns:[[
    			{field:'babyName',title:'名字',width:200,fitColumns:true }
    			,{field:'_operate',title:'操作',width:80,formatter:formatOper}
    			//,{field:'phone',title:'手机',width:200,fitColumns:true }			 
    		]]	
        })
    });
    
    function formatOper(val,row,index){
        return '<a href="#" onclick="deleteApply('+index+')">删除</a>';
    }
    
    var deleteApply = function(index){
    	studentDataGrid.datagrid('selectRow',index);
        var row = studentDataGrid.datagrid('getSelected');
		if(row.id!=''){
			var type = '${course_type}';
			if(type=='1'){
				deleteZj(row.id);
			}else if(type=='2'){
				deleteTb(row.id);
			}else{
				layer.msg('未知课程类型', {time: 3000, icon:6});
			}
		}else{
			layer.msg('请先选择一条记录', {time: 3000, icon:6});
		}
	}
    
    var deleteTb = function(id){
    	$.ajax({
            url: '${path}/course/cancelCareClass',
            type:'POST', 
            data: {care_class_appointment_id:id},
            async:false,
            dataType: 'json',
            success: function(doc) {
            	layer.msg(doc.msg, {time: 3000, icon:6});
				if(doc.status=='1'){
					studentDataGrid.datagrid('reload');
            	}
            }
        });
    }
    
    var deleteZj = function(id){
    	$.ajax({
            url: '${path}/course/cancelCourse',
            type:'POST', 
            data: {course_appointmet_id:id},
            async:false,
            dataType: 'json',
            success: function(doc) {
            	layer.msg(doc.msg, {time: 3000, icon:6});
				if(doc.status=='1'){
					studentDataGrid.datagrid('reload');
            	}
            }
        });
    }
    
    </script>
</head>
<body>
	<table id="studentDataGrid" title="学生列表" class="easyui-datagrid" style="width:465px" singleSelect="true" iconCls="icon-save"></table>
</body>
</html>
